<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<html lang="zh-CN">
<head>
    <meta http-equiv="content-type" content="text/html;charset=UTF-8">
    <style>



        #elinput03 {
            margin-left: 42px;
        }

        #elinput02, #elinput01 {
            margin-left: 35px;
        }

        /*#elinput3{margin-left: 31px;}*/

        /*#elinput2,#elinput1{ margin-left: 30px;}*/

        #groupSearch {
            padding-left: 20px;
        }

        #GroupManage {
            position: relative;
            z-index: 1;
        }

        .group_pop {
            position: absolute;
            top: 14%;
            right: 40%;
            background: white;
            width: 400px;
            height: 300px;
            text-align: center;
            border: 2px rgba(201, 201, 201, 1) solid;
            z-index: 10;
        }

        .groupAdd_pop {
            text-align: center;
            position: absolute;
            top: 20%;
            right: 40%;
            background: white;
            width: 400px;
            border-radius: 5px;
            border: 2px rgba(201, 201, 201, 1) solid;
            z-index: 10;
            height: 280px;
        }

        .treeGroup_div {
            width: 300px;
            position: absolute;
            top: 20%;
            left: 20%;
            border: 2px rgba(201, 201, 201, 1) solid;
            z-index: 1;
        }

        #groupMemberManage_sub_tree {
            height: 344px;
            overflow-x: hidden;
            background: white;
        }

        .showTable {
            position: absolute;
            width: 500px;
            left: 101%;
            top: 0%;
            border: 2px rgba(201, 201, 201, 1) solid;
        }

        .CloseMemberList {
            transform: scale(0.7);
            width: 38px;
            background-color: white;
            position: absolute;
            top: -35px;
            left: 404.5px;
            height: 41px;
        }

        .NewCloseMemberList {
            transform: scale(0.7);
            width: 0px;
            background-color: white;
            position: absolute;
            top: -50px;
            left: 780px;
            height: 40px;
        }

        .groupMemberManage_sub_button {
            background: white;
            text-align: center;
        }

        .queryBtn1 {
            /*margin-left: 40%;*/
        }

        .modifyGroup {
            margin-left: 10px;
        }

        .modify_Group {
            transform: scale(0.7);
        }

        .addMember_title {
            font-weight: 700;
            width: 270.5%;
            background: rgb(27, 92, 166);
            height: 30px;
            position: absolute;
            top: -30px;
            left: -2px;
            font-size: 16px;
            letter-spacing: 9px;
            line-height: 30px;
            text-align: center;
            color: white;
        }

        .addMember_title:hover {
            cursor: move;
        }

    </style>
</head>
<body>
<div id="GroupManage" class="center_div" style="display: none;">
    <div style="float:left;width:19%;background: white;position: absolute;" class="tree_class">
        <div style="height: 90%;overflow:auto;margin-top: 2%">
            <el-tree check-strictly
                     :load="loadChildrenn"
                     highlight-current
                     lazy
                     v-if="loadFleetTree"
                     node-key="id"
                     :props="defaultProps"
                     :filter-node-method="filterNode"
                     ref="tree"
                     @node-click="loadDataaa">
                <span class="custom-tree-node" style="font-size: 14px" slot-scope="{ node, data }">
                    <span v-if="data.type===0"><img src="images/mapicon/tree_fleet.png" style="height: 15px;width: 15px;margin-right: 10px;vertical-align: middle">{{ node.label }}</span>
                    <span v-if="data.type===1"><img src="images/mapicon/tree_fleet.png" style="height: 15px;width: 15px;margin-right: 10px;vertical-align: middle">{{ node.label }}</span>
                </span>
            </el-tree>
        </div>
    </div>
    <div style="float:right;width: 80%">
        <div id="groupSearch" style="margin-top: 1%">
            <span class="groupMan_name">群组名称:</span>
            <el-input v-model="name" size="mini"   style="width: 10%"></el-input>
            <span class="groupMan_groupSearchNumber">群组号码:</span>
            <el-input v-model="number" size="mini" style="width: 10%" type="number" :min="0" onKeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))"></el-input>
            <span class="groupMan_groupSearchNumber">分机号码:</span>
            <el-input v-model="extNumber" size="mini" style="width: 10%" type="number" :min="0" onKeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))"></el-input>
            <span class="groupMan_groupSearchNumber">所属集团:</span>
            <el-select v-model="fleetName" :placeholder="'请选择'" size="mini" filterable clearable>
                <el-option :value="fleetName" style="height: auto">
                    <el-tree
                            :load="loadChildrenn"
                            highlight-current
                            lazy
                            v-if="loadFleetTree"
                            node-key="id"
                            :props="defaultProps"
                            :filter-node-method="filterNode"
                            ref="tree"
                            @node-click="loadData">
                        <span class="custom-tree-node" style="font-size: 14px" slot-scope="{ node, data }">
                            <span v-if="data.type===0"><img src="images/mapicon/tree_fleet.png" style="height: 15px;width: 15px;margin-right: 10px;vertical-align: middle">{{ node.label }}</span>
                            <span v-if="data.type===1"><img src="images/mapicon/tree_fleet.png" style="height: 15px;width: 15px;margin-right: 10px;vertical-align: middle">{{ node.label }}</span>
                        </span>
                    </el-tree>
                </el-option>
            </el-select>
            <span class="groupMan_groupSearchNumber">系统类型:</span>
            <el-select v-model="systemId" :placeholder="'请选择'" size="mini" filterable clearable>
                <el-option
                        v-for="item in systemOptionss"
                        :key="item.System_ID"
                        :label="item.System_alias"
                        :value="item.System_ID">
                </el-option>
            </el-select>
            <el-button class="queryBtn" @click="queryGroup(1)" size="mini" type="primary">查询</el-button>
            <el-button class="addBtn" @click="addGroup"  size="mini" type="primary">新增</el-button>
        </div>
        <div class="table-wrap" style="width: 98%;margin-left: 1%">
            <el-table
                    :data="tableData"
                    style="width:100%;text-align: center;border-left:1px solid #EBEBEB"
                    header-cell-style="font-size:15px;text-align:center;color:#515A6E;padding:10px 0px 10px 0px !important;background:#F5F5F6;border:1px solid #EBEBEB;border-left:none"
                    cell-style="font-size:13px;text-align:center;color:#606266;padding:5px 0px 5px 0px !important;border:1px solid #EBEBEB;border-top:none;border-left:none"
            >
                <el-table-column
                        prop="name"
                        label="群组名称">
                </el-table-column>
                <el-table-column
                        prop="number"
                        label="群组号码">
                </el-table-column>
                <el-table-column
                        prop="sipNumber"
                        label="分机号码">
                </el-table-column>
                <el-table-column
                        prop="priority"
                        label="群组优先级">
                </el-table-column>
                <el-table-column
                        prop="subNum"
                        label="成员数量">
                </el-table-column>
                <el-table-column
                        prop="freeReleaseTime"
                        label="空闲释放时长(s)">
                </el-table-column>
                <el-table-column
                        label="操作"
                        width="180">
                    <template slot-scope="scope">
                        <el-button @click="deleteGroup(scope.$index, tableData)" type="text" size="small">删除</el-button>
                        <el-button @click="modifyGroup(scope.$index, tableData)" type="text" size="small">修改</el-button>
                        <el-button @click="memberManger(scope.row)" type="text" size="small">成员管理</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <el-pagination
                    layout="prev, pager, next"
                    @current-change="changePageNum"
                    :current-page="pageNum"
                    :total="total">
            </el-pagination>
        </div>
    </div>

    <div>
        <el-dialog :title="title"
                   @close="closeDialog"
                   :visible.sync="showDialog"
                   width="30%"
                   append-to-body>
            <el-form ref="form" :model="form" :rules="rules" size="mini" label-width="130px">
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="群组名称" prop="name">
                            <el-input v-model="form.name" clearable></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="群组号码" prop="number">
                            <el-input v-model="form.number" clearable type="number" :min="0" onKeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="空闲释放时长" prop="freeReleaseTime">
                            <el-input v-model="form.freeReleaseTime" clearable type="number" :min="0" onKeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="优先级" prop="priority">
                            <el-select v-model="form.priority" placeholder="请选择">
                                <el-option
                                        v-for="item in options"
                                        :key="item.value"
                                        :label="item.label"
                                        :value="item.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="归属集团" prop="fleetName" v-show="form.type!=1">
                            <el-select v-model="form.fleetName" :placeholder="'请选择'" >
                                <el-option :value="form.fleetName" style="height: auto">
                                    <el-tree
                                            :load="loadChildrenn"
                                            highlight-current
                                            lazy
                                            node-key="id"
                                            :props="defaultProps"
                                            :filter-node-method="filterNode"
                                            ref="tree"
                                            @node-click="loadDataa">
                                        <span class="custom-tree-node" style="font-size: 14px" slot-scope="{ node, data }">
                                            <span v-if="data.type===0"><img src="images/mapicon/tree_fleet.png" style="height: 15px;width: 15px;margin-right: 10px;vertical-align: middle">{{ node.label }}</span>
                                            <span v-if="data.type===1"><img src="images/mapicon/tree_fleet.png" style="height: 15px;width: 15px;margin-right: 10px;vertical-align: middle">{{ node.label }}</span>
                                        </span>
                                    </el-tree>
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="系统类型" prop="System_ID">
                            <el-select v-model="form.System_ID" placeholder="请选择">
                                <el-option
                                        v-for="item in systemOptions"
                                        :key="item.System_ID"
                                        :label="item.System_alias"
                                        :value="item.System_ID">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="showDialog = false" size="mini">取 消</el-button>
                <el-button type="primary" @click="dialogComfirm" size="mini">确 定</el-button>
            </div>
        </el-dialog>
    </div>


    <!----添加成员---->

    <el-dialog v-if="loadTree" :title="title" :visible.sync="addShow" @close="dialogClose" append-to-body>
        <div>
            <div style="float:left;width:35%;height:300px">
                <div style="height:99%;width:99%;margin-top:1%;background:white;overflow:auto">
                    <el-tree check-strictly
                             :load="loadChildren"
                             show-checkbox
                             highlight-current
                             lazy
                             node-key="id"
                             :props="defaultProps"
                             :filter-node-method="filterNode"
                             ref="tree"
                             @check-change="handleCheckChange">
                            <span class="custom-tree-node" style="font-size: 14px" slot-scope="{ node, data }">
                                <span v-if="data.type===0"><img src="images/mapicon/tree_fleet.png"
                                                                style="height: 15px;width: 15px;margin-right: 10px;vertical-align: middle">{{ node.label }}</span>
                                <span v-if="data.type===1"><img src="images/mapicon/tree_fleet.png"
                                                                style="height: 15px;width: 15px;margin-right: 10px;vertical-align: middle">{{ node.label }}</span>
                                <span v-if="data.type===2"><img src="images/mapicon/tree_sub.png"
                                                                style="height: 15px;width: 15px;margin-right: 10px;vertical-align: middle">{{ node.label }}</span>
                            </span>
                    </el-tree>
                </div>
            </div>
            <div style="float:right;width:65%;height:300px;background: ghostwhite;overflow: auto">
                <el-row>
                    <el-col :span="5">
                        <span style="text-overflow:ellipsis">名称</span>
                    </el-col>
                    <el-col :span="5">
                        <span style="text-overflow:ellipsis">号码</span>
                    </el-col>
                    <el-col :span="5">
                        <span style="text-overflow:ellipsis">成员优先级</span>
                    </el-col>
                    <el-col :span="5">
                        <span style="text-overflow:ellipsis">说话时长</span>
                    </el-col>
                    <el-col :span="4">
                        <span style="text-overflow:ellipsis">操作</span>
                    </el-col>
                </el-row>
                <el-row v-for="item in memberTableData" :key="item.id" style="padding: 3px">
                    <el-col :span="5" style="padding-top: 5px;font-size: 13px">
                        <span style="text-overflow:ellipsis">
                            {{item.name}}
                        </span>
                    </el-col>
                    <el-col :span="5" style="padding-top: 5px;font-size: 13px">
                        <span style="text-overflow:ellipsis">
                            {{item.subNumber}}
                        </span>
                    </el-col>
                    <el-col :span="5" style="padding-top: 5px;font-size: 13px">
                        <el-select v-model="item.priority" size="mini" style="width: 80px">
                            <el-option
                                    v-for="item in memberPriority"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                            </el-option>
                        </el-select>
                    </el-col>
                    <el-col :span="5" style="padding-top: 5px;font-size: 13px">
                        <el-input v-model="item.time" size="mini" style="width: 70px"></el-input>
                    </el-col>
                    <el-col :span="4">
                        <el-button @click="deleteMember(item.subId)" class="el-button el-button--text el-button--medium">
                            删除
                        </el-button>
                    </el-col>
                </el-row>
            </div>
        </div>
        <div style="margin-top: 20px;margin-left: 90%">
            <el-button type="primary" size="mini" @click="addGroupMember">确定</el-button>
        </div>
    </el-dialog>
</div>
</body>
<script>
    VueComponent.createGroupManage = function () {
        if (window.groupManageVue) {
            return;
        }
        window.groupManageVue = new Vue({
            el: "#GroupManage",
            data: {
                groupSearchName: "",
                groupSearchNumber: "",
                groupSearchPriority: "",
                name: "",
                number: "",
                extNumber:"",
                systemName:"",
                systemId:"",
                priority: "",
                tableData: [],
                total: 0,
                pageNum: 1,
                pageSize: 10,
                groupId: "",
                namem: "",
                form: {
                    name: "",
                    groupId: 0,
                    type: 0, // 0-添加 1-修改
                    number: "",
                    priority: "",
                    freeReleaseTime: 60,
                    System_ID:'',
                    fleetName:'',
                    fleetId:'',
                },
                rules: {
                    name: [
                        {required: true, message: '请输入群组名称', trigger: 'blur'},
                        {min: 1, max: 16, message: '长度在 1 到 16 个字符', trigger: 'blur'}
                    ], number: [
                        {required: true, message: '请输入群组号码', trigger: 'blur'},
                        {min: 1, max: 16, message: '长度不能超过16个字符', trigger: 'blur'}
                    ], priority: [
                        {required: true, message: '请选择优先级', trigger: 'blur'},
                    ], freeReleaseTime: [
                        {required: true, message: '请输入空闲释放时长', trigger: 'blur'},
                        {
                            pattern: /^[5-9]$|^[1]\d$|^[2-9]\d$|^[1-8]\d{2}$|900/,
                            message: '时长必须在5-900秒之间',
                            trigger: 'blur'
                        },

                    ],
                },
                numberm: "",
                prioritym: "",
                freeReleaseTimem: 0,
                options: [{
                    value: 0,
                    label: '0-最高'
                }, {
                    value: 1,
                    label: '1'
                }, {
                    value: 2,
                    label: '2'
                }, {
                    value: 3,
                    label: '3'
                }, {
                    value: 4,
                    label: '4'
                }, {
                    value: 5,
                    label: '5'
                }, {
                    value: 6,
                    label: '6-最低'
                }, {
                    value: 7,
                    label: '7-普通工作组'
                },],
                query: '7',
                memberPriority: [{
                    value: 0,
                    label: '0-最高'
                }, {
                    value: 1,
                    label: '1'
                }, {
                    value: 2,
                    label: '2'
                }, {
                    value: 3,
                    label: '3'
                }, {
                    value: 4,
                    label: '4'
                }, {
                    value: 5,
                    label: '5'
                }, {
                    value: 6,
                    label: '6'
                }, {
                    value: 7,
                    label: '7-最低'
                }],
                defaultProps: {
                    label: 'name',
                    isLeaf: 'isLeaf'
                },
                isShowTree: true,
                addShow: false,
                showDialog: false,
                tableData1: [],
                currentAddGroup: "",     //当前群组id
                currentIndex: "",           //当前选择的列数
                currentContent: [],          //当前列信息
                flag: true,
                Nodesname: "",
                Nodesid: "",
                modifyPriority: "",
                value: 7,
                namea: "",
                numbera: "",
                freeReleaseTimea: "",
                loadTree: true,
                memberTableData: [],
                title: '',
                fleetName:'',
                fleetId:'',
                loadFleetTree:true,
                systemOptions:[],
                systemOptionss:[]
            },
            mounted: function () {
                this.$nextTick(function () {
                    this.queryGroupList();
                    this.getSystem(window.fleetId);
                })
            },
            methods: {
                getSystem:function (fleetId) {
                    var that=this;
                    that.systemOptions=[];
                    that.systemOptionss=[];
                    axios.post('/scs/fleetManage/getFleetSystem', {fleetId:fleetId})
                        .then(function (res) {
                            if (res.status === 200) {
                                var data = res.data;
                                if (res.data.success) {
                                    that.systemOptions=data.obj.list;
                                    that.systemOptionss=data.obj.list;
                                    that.systemOptionss.unshift({System_alias:"全部",System_ID:""});
                                } else {
                                    that.$message(res.msg);
                                }
                            } else {
                                that.$message(res.msg);
                            }
                        }.bind(this)).catch(function () {

                    }.bind(this));
                },
                refreshNodeBy:function(){
                    var node = this.$refs.tree.getNode(window.fleetId);
                    node.loaded = false;
                    node.expand();
                    window.groupManageVue.loadFleetTree = false;
                    this.$nextTick(function () {
                        window.groupManageVue.loadFleetTree = true;
                    });
                },
                loadData:function (node) {
                    this.fleetName = node.name;
                    this.fleetId = node.id;
                    // this.getSystem(node.id);
                },
                loadDataa:function (node) {
                    this.form.fleetName = node.name;
                    this.form.fleetId = node.id;
                    this.getSystem(node.id);
                },
                loadDataaa:function (node) {
                    var that = this;
                    var data = {
                        fleetId: node.id,
                        pageNum: 1,
                        pageSize: that.pageSize,
                    }
                    axios.post('/scs/group/queryGroup', data)
                        .then(function (res) {
                            var list = res.data.rows;
                            if (res != null) {
                                groupManageVue.tableData = list;
                                groupManageVue.total = res.data.total;
                            }
                        })
                        .catch(function (err) {
                            console.warn(err);
                        });
                },
                loadChildrenn: function (node, resolve) {
                    var that = this;
                    if (node.data) {
                        that.getChildd(node.data.id, node.data.type, resolve);
                    } else {
                        setTimeout(function () {
                            that.getChildd(window.fleetId, 0, resolve);
                        }, 0);
                    }
                },
                getChildd: function (id, type, resolve) {
                    var jsonData = {
                        parentId: id,
                        type: type
                    };
                    axios.post('/scs/fleetManage/getFleet', jsonData)
                        .then(function (res) {
                            res = res.data;
                            if (res.success) {
                                var childNodes = [];
                                if (res.obj) {
                                    childNodes = res.obj;
                                }
                                resolve(childNodes);
                            }
                        })
                        .catch(function (error) {
                            console.log(error);
                        });
                },
                closeDialog(){
                    this.$refs["form"].resetFields();
                },
                addGroupMember: function () {
                    var that = this;
                    axios.post('/scs/group/addGroupMemberNew', {
                        groupId: that.groupId,
                        memberTableData: that.memberTableData
                    })
                        .then(function (res) {
                            var res = res.data;
                            if (res.success) {
                                if (res.obj.count === 1) {
                                    that.addShow = false;
                                    that.$message('操作成功');
                                    that.queryGroupList();
                                } else {
                                    that.$message('操作失败');
                                }
                            } else {
                                that.$message('操作失败');
                            }
                        })
                        .catch(function (err) {
                            console.log(err);
                        });
                },
                dialogClose(){
                    window.groupManageVue.loadTree = false;
                    setTimeout(function () {
                        window.groupManageVue.loadTree = true;
                    }, 100);
                },
                deleteMember: function (id) {
                    for (var i = 0; i < this.memberTableData.length; i++) {
                        if (id === this.memberTableData[i].subId) {
                            this.memberTableData.splice(i, 1);
                            var node = window.groupManageVue.$refs.tree.getNode(id);
                            node.checked = false;
                        }
                    }
                },
                handleCheckChange: function (data, checked, indeterminate) {
                    if (checked) {
                        var nodeObj = {};
                        nodeObj.subId = data.id;
                        nodeObj.subNumber = data.number;
                        nodeObj.priority = 7;
                        nodeObj.time = 60;
                        if (data.name.length > 10) {
                            nodeObj.name = data.name.substring(0, 10) + '...';
                        } else {
                            nodeObj.name = data.name;
                        }
                        var length = false;
                        for (var i = 0; i < this.memberTableData.length; i++) {
                            if (data.id === this.memberTableData[i].subId) {
                                length = true;
                            }
                        }
                        if (!length) {
                            this.memberTableData.push(nodeObj);
                        }
                    } else if (!checked) {
                        for (var i = 0; i < this.memberTableData.length; i++) {
                            if (data.id === this.memberTableData[i].subId) {
                                this.memberTableData.splice(i, 1);
                            }
                        }
                    }
                },
                loadChildren: function (node, resolve) {
                    var that = this;
                    if (node.data) {
                        if (node.data.type === 2) {
                            var childNodes = [];
                            return resolve(childNodes);
                        } else {
                            that.getChild(node.data.id, node.data.type, resolve);
                        }
                    } else {
                        setTimeout(function () {
                            that.getChild(window.fleetId, 0, resolve);
                        }, 0);
                    }

                },
                getChild: function (id, type, resolve) {
                    var jsonData = {
                        initID: window.fleetId,
                        parentId: id,
                        type: type,
                        userId: window.DasConstant.userId,
                        managePriv: window.managePriv
                    };
                    axios.post('/scs/Subscriber/getTalk', jsonData)
                        .then(function (res) {
                            res = res.data;
                            if (res.success) {
                                var childNodes = [];
                                if (res.obj && res.obj.length > 0) {
                                    for (var i = 0; i < res.obj.length; i++) {
                                        if (res.obj[i].type === 2) {
                                            res.obj[i].isLeaf = true;
                                        }
                                    }
                                    childNodes = res.obj;
                                } else {
                                    var node = window.groupManageVue.$refs.tree.getNode(id);
                                    node.loading = false;
                                    return
                                }
                                resolve(childNodes);
                            }
                        })
                        .catch(function (error) {
                            console.log(error);
                        });
                    setTimeout(function () {
                        for (var i = 0; i < window.groupManageVue.memberTableData.length; i++) {
                            var node = window.groupManageVue.$refs.tree.getNode(window.groupManageVue.memberTableData[i].subId);
                            if (node != null && node.checked === false) {
                                node.checked = true;
                            }
                        }
                    }, 200);
                },
                getTreeNodes: function () {                            //确定
                    var that = this;
                    var nodes = that.$refs.tree.getCheckedNodes();
                    for (var i = 0; i < nodes.length; i++) {
                        if (nodes[i].type == "1") {
                            swal('提示！', "只能添加终端", 'error');
                            return;
                        }
                        groupManageVue.Nodesname = nodes[i].name;
                        groupManageVue.Nodesid = nodes[i].id;
                        groupManageVue.flag = true;
                        axios.post('/scs/group/queryGroupMember', {
                            "userNumber": nodes[i].number,
                            "groupId": groupManageVue.currentAddGroup
                        })
                            .then(function (res) {
                                var list = res.data.rows;
                                if (list.length != 0) {
                                    groupManageVue.flag = false;
                                    swal('提示！', groupManageVue.Nodesname + "已在群组中", 'error');
                                    return;
                                }

                            })
                            .catch(function (err) {
                                console.warn(err);
                            });
                        setTimeout(function () {
                            if (groupManageVue.flag) {
                                for (var i = 0; i < nodes.length; i++) {
                                    axios.post('/scs/group/addGroupMember', {
                                        subscriberIds: nodes[i].id,
                                        groupId: groupManageVue.currentAddGroup
                                    })
                                        .then(function (res) {
                                            if (res.status == "200") {
                                                //更新成员表
                                                var data = {"groupId": groupManageVue.currentAddGroup};
                                                axios.post('/scs/group/queryGroupMember', data)
                                                    .then(function (res) {
                                                        if (res.status == "200") {
                                                            var infos = res.data.rows;
                                                            groupManageVue.tableData1 = []; //清空之前防止二次
                                                            infos.forEach(function (item) {
                                                                groupManageVue.tableData1.push(item);
                                                            });
                                                            // groupManageVue.simulateData();
                                                            // groupManageVue.isShowTree = false;
                                                        }
                                                    })
                                                    .catch(function (err) {
                                                        console.warn(err);
                                                    });
                                                ScsCommEvent.ScsAlertLayer("添加成功", false, false, false);
                                            }
                                        })
                                        .catch(function (err) {
                                            console.warn(err);
                                        });
                                }
                            }
                        }, 200)

                    }
                    that.$refs.tree.setCheckedKeys([]);
                },
                cancelTree: function () {                      //取消树
                    this.$refs.tree.setCheckedKeys([]);
                },
                filterNode: function (value, data) {
                    if (!value) return true;
                    return data.name.indexOf(value) !== -1;
                },
                queryGroupList: function () {
                    var that = this;
                    var data = {
                        fleetId: that.fleetId || DasConstant.fleetId[0].fid,
                        pageNum: that.pageNum,
                        pageSize: that.pageSize,
                    }
                    axios.post('/scs/group/queryGroup', data)
                        .then(function (res) {
                            var list = res.data.rows;
                            if (res != null) {
                                groupManageVue.tableData = list;
                                groupManageVue.total = res.data.total;
                            }
                        })
                        .catch(function (err) {
                            console.warn(err);
                        });
                },
                queryGroup: function (pageNum) {
                    var data = {
                        fleetId: this.fleetId || DasConstant.fleetId[0].fid,
                        name: this.name,
                        number: this.number,
                        extNumber:this.extNumber,
                        systemId:this.systemId,
                        priority: this.priority,
                        pageNum: this.pageNum,
                        pageSize: this.pageSize,
                    };
                    axios.post('/scs/group/queryGroup', data)
                        .then(function (res) {
                            var list = res.data.rows;
                            if (res != null) {
                                groupManageVue.tableData = list;
                                groupManageVue.total = res.data.total;
                            }
                        })
                        .catch(function (err) {
                            console.warn(err);
                        });
                },
                changePageNum: function (val) {
                    this.pageNum = val;
                    this.queryGroupList();
                },
                addGroup: function () {
                    this.formClear();
                    this.form.type=0;
                    axios.post('/scs/group/getGroupNumber', {})
                        .then(function (res) {
                            if (res.data.success) {
                                window.groupManageVue.$data.numbera = res.data.obj;
                                window.groupManageVue.showDialog = true;
                            } else {
                                ScsCommEvent.ScsAlertLayer(res.data.msg, false, false, false);
                                return;
                            }
                        })
                        .catch(function (err) {
                            console.warn(err);
                        });
                },
                dialogComfirm: function () {
                    console.info("dialogComfirm");
                    var that = this;
                    var validate = false;
                    this.$refs["form"].validate((valid) => {
                        if (valid) {
                            validate = true;
                        } else {
                            console.log('error submit!!');
                            validate = false;
                            return false;
                        }
                    });
                    if (validate === false) {
                        return;
                    }
                        if(this.form.type === 0 ){

                            var data = {
                                fleetId: this.form.fleetId,
                                fleetName: this.form.fleetName,
                                name: this.form.name,
                                number: this.form.number,
                                priority: this.form.priority,
                                freeReleaseTime: this.form.freeReleaseTimea,
                                systemId: this.form.System_ID,
                                userId: DasConstant.userId
                            };
                            axios.post('/scs/group/addGroupByDC', data)
                                .then(function (res) {
                                    if (res.data.success) {
                                        //更新表
                                        that.showDialog = false;
                                        that.tableData = []; //清空之前防止二次
                                        that.$message('添加成功');
                                        that.queryGroupList();
                                         ScsTree.refreshTree()

                                    } else {
                                        that.$message(res.data.msg);

                                    }


                                })
                                .catch(function (err) {
                                    console.warn(err);
                                });
                        }else {
                            var that = this;
                            var data = {
                                groupId: this.form.groupId,
                                fleetId: this.form.fleetId,
                                fleetName: this.form.fleetName,
                                name: this.form.name,
                                number: this.form.number,
                                priority: this.form.priority,
                                freeReleaseTime: this.form.freeReleaseTime,
                                systemId: this.form.System_ID,
                            }
                            axios.post('/scs/group/updateGroup', data)
                                .then(function (res) {
                                    if (res.data.success) {
                                        that.showDialog = false;
                                        that.$message('修改成功');
                                        that.queryGroupList();
                                    } else {
                                        that.$message('修改失败');
                                    }

                                })
                                .catch(function (err) {
                                    console.warn(err);
                                });
                        }

                },
                deleteGroup: function (row, table) {
                    var that = this;
                    this.$confirm('是否确定删除', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }).then(() => {
                        var data = {};
                        var groupId = table[row].groupId;
                        axios.post('/scs/group/deleteGroup?groupId=' + groupId + '', data)
                            .then(function (res) {
                                if (res.status == "200") {
                                    table.splice(row, 1);
                                    that.$message('删除成功');
                                    const totalPage = Math.ceil((that.total - 1) / that.pageSize);
                                    //记住删除最后一条数据时当前码是最后一页
                                    const tempPageNum = that.pageNum > totalPage ? totalPage : that.pageNum;
                                    //实现跳转
                                    that.pageNum = tempPageNum < 1 ? 1 : tempPageNum;
                                    that.queryGroup();
//                                    ScsCommEvent.ScsAlertLayer("群组已删除", false, false, false);
                                    ScsTree.refreshTree()
                                }else {
                                    that.$message('删除失败');

                                }
                            })
                            .catch(function (err) {
                                that.$message('删除失败');
                            });

                    });

                },
                modifyGroup: function (index, rows) {
                    this.form.fleetId = rows[index].fleetId;
                    this.form.fleetName = rows[index].fleetName;
                    this.form.name = rows[index].name;
                    this.form.number = rows[index].number;
                    this.form.priority = rows[index].priority;
                    this.form.freeReleaseTime = rows[index].freeReleaseTime;
                    this.form.System_ID = rows[index].systemId;
                    this.form.groupId = rows[index].groupId;
                    this.form.type = 1;
                    this.getSystem(rows[index].fleetId);
                    this.$nextTick(function () {
                        this.showDialog = true;
                    });
                    this.currentIndex = index;
                    this.currentContent = rows[index];
                },
                memberManger: function (row) {
                    console.log(row);
                    this.addShow = true;
                    this.title = "成员管理";
                    this.groupId = row.groupId;
                    var data = {
                        groupId: row.groupId,
                    }
                    axios.post('/scs/group/queryGroupMember', data)
                        .then(function (res) {
                            if (res.status == "200") {
                                window.groupManageVue.$data.memberTableData = res.data.rows;
                            }
                        })
                        .catch(function (err) {
                            console.warn(err);
                        });
                },
                deleteRow: function (index, rows) {
                    ScsCommEvent.ScsAlertLayer("确认删除？", false, true, closeChannel3, null, null);
                    function closeChannel3() {
                        var data = {
                            subscriberId: rows[index].subId,
                            groupId: rows[index].groupId
                        }
                        axios.post('/scs/group/deleteGroupMember', data)
                            .then(function (res) {
                                if (res.status == "200") {
                                    rows.splice(index, 1);
                                    ScsCommEvent.ScsAlertLayer("删除成功", false, false, false);
                                }
                            })
                            .catch(function (err) {
                                console.warn(err);
                            });
                    }
                },
                modifyMemberInfo: function (index, rowInfo) {
                    if (rowInfo.subId == undefined) {
                        return;
                    }
                    var data = {
                        groupId: rowInfo.groupId,
                        subscriberId: rowInfo.subId,
                        priority: rowInfo.priority,
                        speakTime: rowInfo.time
                    }
                    axios.post('/scs/group/updateGroupMember', data)
                        .then(function (res) {
                            if (res.status == "200") {
                                ScsCommEvent.ScsAlertLayer("成功", false, false, false);
                            }
                        })
                        .catch(function (err) {
                            console.warn(err);
                        });
                },
                CloseMemberList: function () {
                    this.addShow = false;
                },
                formClear:function () {
                    this.form.fleetId='';
                    this.form.fleetName='';
                    this.form.name='';
                    this.form.number='';
                    this.form.freeReleaseTime=60;
                    this.form.priority='';
                    this.form.System_ID='';
                    this.systemOptions=[];
                },
            }
        });
    }
</script>
</html>
